#查询余额
def atm_query():
    print('当前余额 %s' % float('%.2f' % user_db[user_now][1]))
    print('===============')
    atm_manager()

#充值
def atm_recharge(money):
    global user_db
    user_db[user_now][1] = user_db[user_now][1] + money
    print("充值成功 充值金额 %s" % money)
    atm_query()

#提现
def atm_withdraw(money):
    global user_db
    if user_db[user_now][1] >= money:
        user_db[user_now][1] = user_db[user_now][1] - money
        print('提现成功 提现 %s' % money)
        atm_query()
    else:
        print('金额不足')
        atm_query()

#默认登陆
def atm_default():
    print(' ===== ATM默认页面 欢迎登陆 =====')
    u = input('输入账号: ')
    ps = input('输入密码: ')
    atm_login(u,ps)

#登陆用户判断
def atm_login(u,pw):
    print('===============')
    if u not in user_db.keys():
        print('账号错误')
        atm_default()
    else:
        if pw != user_db[u][0]:
            print('密码错误')
            atm_default()
        else:
            print('登陆成功')
            global user_now
            user_now = u
            atm_manager()

#登陆后执行操 提示页
def atm_manager():
    print('===============')
    global user_now
    print('当前用户 %s ' % user_now)
    print('查询 输入 1')
    print('充值 输入 2')
    print('提现 输入 3')
    print('退出 输入 4')
    numb = input('请输入选择: ')
    print('===============')
    if numb == "1":
        atm_query()
    elif numb == "2":
        money = float(input('输入需要充值的金额'))
        print(money)
        atm_recharge(money)
    elif numb == "3":
        money = float(input('输入需要提现的金额'))
        atm_withdraw(money)
    elif numb == "4":
        user_now = 'none'
        atm_default()
    else:
        print('输入错误')
        atm_manager()

#执行
if __name__ == '__main__':
    #存储用户信息
    user_db = {'admin': ['123456', float(111.11)], 'test01': ['123', float(33)]}
    #保存当前登陆用户信息
    user_now = 'none'
    atm_default()